feat: collect API request/response data in error reporter#201
Merged
Conversation
When an ApiError is thrown, the error reporter now automatically extracts request URL, method, status code, and response body from the error and includes them in telemetry. This removes the unused manual ErrorContext.api field in favor of auto-extraction from ApiError instances in buildProperties. https://claude.ai/code/session_01WsgRcUXSBY5v1TppPoDdwZ
Contributor
🚀 Package Preview Available!Install this PR's preview build with npm: npm i @base44-preview/cli@0.0.28-pr.201.978b427Prefer not to change any import paths? Install using npm alias so your code still imports npm i "base44@npm:@base44-preview/cli@0.0.28-pr.201.978b427"Or add it to your {
"dependencies": {
"base44": "npm:@base44-preview/cli@0.0.28-pr.201.978b427"
}
}
Preview published to npm registry — try new features instantly! |
Code ReviewI found one issue that should be addressed: Missing CLAUDE.md Documentation UpdateFile: This PR adds automatic extraction of API request/response data from
Why this matters:
Suggested fix: - API error details (automatically extracted from ApiError instances):
- Request URL and HTTP method
- Response status code
- Response bodySummary: 1 issue found related to CLAUDE.md adherence. No bugs detected in the implementation. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
Description
This PR enhances API error telemetry by automatically capturing comprehensive request and response details when
ApiErroris thrown. The error reporter now extracts HTTP method, URL, status code, request body, and response body directly fromApiErrorinstances, eliminating the need for manual context setting and providing richer debugging information for production API failures.Related Issue
Fixes #185
Type of Change
Changes Made
ApiErrorclass with new properties:requestUrl,requestMethod,requestBody,responseBody, andstatusCodecaptureRequestBody()hook tobase44Clientthat clones requests and stores body inoptions.context.__requestBodyfor later extractionApiError.fromHttpError()to extract request URL, method, body (from context), and response body fromHTTPErrorinstancesErrorReporter.buildProperties()to automatically extract API data fromApiErrorinstances and include as telemetry properties (api_request_url,api_request_method,api_request_body,api_response_body,api_status_code)ErrorContext.apifield in favor of automatic extraction patternApiErrorResponseSchemato handle nullable fields (details,traceback,extra_data) for more robust API error parsingTesting
bun test)Checklist
Additional Notes
This change is fully backwards-compatible and improves observability for API errors without requiring any changes to existing error handling code. The telemetry now automatically includes five new properties when an
ApiErroris captured:api_request_url,api_request_method,api_request_body,api_response_body, andapi_status_code. The request body capture uses request cloning to avoid consuming the original request stream.🤖 Generated by Claude | 2026-02-08 17:32 UTC